package l1cache

import (
	"log"
	"math/rand"
	"reflect"
	"time"

	"github.com/bxcodec/faker"
)

func init() {
	rand.Seed(time.Now().UnixNano())
}

var (
	gameidList = []int32{1000, 1001, 1002, 1003, 1004, 1009, 1022, 1037}
	uidList    = []string{"20001", "20002", "20003", "20004", "20005", "20006", "20007", "20008", "20009", "20010"}
)

func oneOfGameid(results []int32) int32 {
	return results[rand.Intn(len(results))]
}

func oneOfUid(results []string) string {
	return uidList[rand.Intn(len(results))]
}

// DebugSetupProvider _
func DebugSetupProvider() {
	err := faker.AddProvider("enum-gameidlist", func(v reflect.Value) (interface{}, error) {
		return oneOfGameid(gameidList), nil
	})
	if err != nil {
		log.Fatalln("add faker provider fail:", err)
	}

	err = faker.AddProvider("enum-uidlist", func(v reflect.Value) (interface{}, error) {
		return oneOfUid(uidList), nil
	})
	if err != nil {
		log.Fatalln("add faker provider fail:", err)
	}
}
